﻿namespace GameStates
{
    public class StateMachine
    {
        private State m_CurrentState;
        public State CurrentState => m_CurrentState;
        public void ChangeState(State newState)
        {
            m_CurrentState?.OnExit();
            m_CurrentState = newState;
            m_CurrentState?.OnEnter();
        }
        
        public void Update()
        {
            m_CurrentState?.Update();
        }
        
        public void FixedUpdate()
        {
            m_CurrentState?.FixedUpdate();
        }
    }
}